/**
 * Created by zhouli on 18/1/30
 * Email li.zhou@huilianyi.com
 */
import React from 'react';
import {connect} from 'react-redux';
import {
  Checkbox, Switch,
  Button, Icon, Menu, Dropdown, Input, Modal,
  Popover, Upload, message, Spin
} from 'antd';
import {deepCopy, messages} from "share/common";
import ImportErrInfo from 'components/template/import-err-info';
import FileSaver from 'file-saver';
import OrgTree from 'containers/enterprise-manage/org-structure/org-component/org-tree';
import OrgSearchList from 'containers/enterprise-manage/org-structure/org-component/org-search-list';
import PDService from 'containers/enterprise-manage/person-manage/person-detail/person-detail.service';
import OrgPersonInfo from 'containers/enterprise-manage/org-structure/org-component/org-person-info';
import OrgRoles from 'containers/enterprise-manage/org-structure/org-component/org-roles';
import 'styles/enterprise-manage/org-structure/org-structure.scss';
import OrgService from 'containers/enterprise-manage/org-structure/org-structure.service';
import {SelectDepOrPerson} from 'components/index';
import menuRoute from 'routes/menuRoute';
import {getErrorMessage} from 'share/errorMessage';
import SlideFrame from 'components/slide-frame';
import OrgNewDep from 'containers/enterprise-manage/org-structure/org-component/org-new-dep';
import ExportModal from 'components/template/export-modal/export-modal';
import Chooser from 'components/chooser';
import configureStore from 'stores';
import {
  setEnableDepCompany,
} from 'actions/setting';
import ResizeTable from 'components/resize-table';
import {superThrottle, getSubText} from 'share/common';
const treeData = [];
const confirm = Modal.confirm;
const Search = Input.Search;
class OrgStructure extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      moveing: false,
      visibleForCheckDepCompany: false,
      companyOID: undefined,//用来过滤公司
      companyName: undefined,//用来过滤公司
      isEnableDepCompany: "INIT",//部门是否关联公司
      showImportBankModel: false,//导入弹窗
      showImportDepRoleModel: false,
      showImportErrInfo: false,
      showImportErrInfoForDepRole: false,

      progressImportErrInfo: 1,
      transactionOID: null,
      errorsList: [],
      fileList: [],
      flieUploading: false,//文件是否正在上传

      showDisabledDepChange: false,//显示停用的部门

      //新增部门，编辑部门
      slideFrame: {
        title: "",
        visible: false,
        params: {}
      },
      visibleBatchAdjustment: false,//批量调整的模态框：是否显示
      batchAdjustmentFrom: [],//批量调整的数据：源
      batchAdjustmentTo: [],//批量调整的数据：目标
      loadingBatchAdjustment: false,//批量调整点击确认
      disabledBatchAdjustment: true,//批量调整 确认按钮 disabled
      userDepName: '',//搜索关键字：员工姓名与部门编码，部门名称
      userName: '',//搜索关键字：员工工号与姓名
      treeData: treeData,//部门树数据
      selectedKeys: [],//当前被选中的部门，默认展示第一个
      selectedKeysDepData: {},//当前被选中的部门的数据
      selectedKeysDepDataByApi: {},//当前被选中的部门通过api查询的详情
      roleIsEdit: false,//部门角色是否正在编辑
      loading: true,
      expandedKeys: [],
      autoExpandParent: true,
      pagination: {
        current: 1,
        page: 0,
        total: 0,
        pageSize: 10,
        showSizeChanger: true,
        showQuickJumper: true,
        pageSizeOptions: ['10','20','30','40'],
      },
      // 部门人员数据
      depUserData: [],
      // 表格
      columns: [
        {
          title: messages('enterprise-manage.key174'/*工号*/),
          key: "employeeId",
          dataIndex: 'employeeId',
          width: '10%',
        },
        {
          width: '20%',
          title: messages('enterprise-manage.key175'/*姓名*/),
          key: "fullName",
          dataIndex: 'fullName',
          render: text => <span>{text ? <Popover placement="topLeft" content={text}>{text}</Popover> : '-'}</span>
        },
        {
          title: messages('enterprise-manage.key176'/*联系方式*/),
          key: "mobile",
          dataIndex: 'mobile',
          render: text => <span>{text ? <Popover placement="topLeft" content={text}>{text}</Popover> : '-'}</span>
        },
        {
          title: messages('enterprise-manage.key177'/*邮箱*/),
          key: "email",
          dataIndex: 'email',
          render: text => <span>{text ? <Popover placement="topLeft" content={text}>{text}</Popover> : '-'}</span>
        },
        {
          title: messages('enterprise-manage.key238')/*职位*/,
          key: "position",
          dataIndex: 'position'
        },
        //这个列下期把人员信息详情做好之后才显示
        {
          title: messages('enterprise-manage.key179'/*操作*/), key: "operation", dataIndex: 'operation',
          width: '10%',
          render: (text, record) => (
            <span>
             <a onClick={(e) => this.useDetail(e, record)}>{messages('common.detail')}</a>
           </span>
          )
        }
      ],
      isSearchOver: false,//是否正在搜索
      //被选择了的人:要移除的人的key,用来翻页
      selectedRowKeys: [],
      //组织架构搜索结果
      searchList: {
        depList: [],
        personList: []
      },
      searchActiveUser: {},//搜索部门树部门与成员，被选中的成员
      depNeedMoveOut: [],//当前部门要移除的人
      downloading: false,
      listLoading: false,
    }
  }

  componentDidMount() {
    /*
    * 人员导入方式：this.props.company.createDataType 如果是 1002，属于接口导入
    * 新增部门,批量调整,部门编辑,部门停用启用, 子部门加减 都要禁止
    * 不然账号切换之后还存在
    * */
    OrgService.resetTreeList();
    this.getTenantAllDep();
    this.checkEnableDepCompany();
    this.getCompanyModeDep();
  }
  // 获取公司模式的部门树
  getCompanyModeDep = () => {
    const {tenantMode, company, enableDepCompany} = this.props;
    /*
    * 满足：
    * 开启部门关联公司
    * 不是租户模式
    * */
    if(!tenantMode && enableDepCompany === "OPEN"){
      let _company = [
        {
          companyName:company.name,
          companyOID:company.companyOID
        }
      ]
      this.handleCompanyFilterChange(_company)
    }
  };

  //检测部门是否关联公司
  checkEnableDepCompany = () => {
    OrgService.checkEnableDepCompany()
      .then(res => {
        configureStore.store.dispatch(setEnableDepCompany(res.data.companyControlStatus));
        this.setState({
          isEnableDepCompany: res.data.companyControlStatus
        })
      })
  };
  //用户详情页面
  useDetail = (e, record) => {
    let path = menuRoute.getRouteItem('person-detail', 'key').url.replace(":userOID", record.userOID);
    this.context.router.push(path);
  };
  //角色设置页面
  goToRolesList = () => {
    this.context.router.push(menuRoute.getMenuItemByAttr('org-structure', 'key').children.orgStructureRolesList.url);
  };

  //部门扩展字段页面
  goToDepartmentExtendFiled = () => {
    this.context.router.push(menuRoute.getMenuItemByAttr('org-structure', 'key').children.DepartmentExtendFiled.url);
  };

  // todo 待优化 用导入组件start
  // ---------------批量设置角色  start------------------
  //批量设置角色
  batchSettingRole = () => {
    this.setState({
      showImportDepRoleModel: true
    })
  };
  cancelImportForPerson = () => {
    this.setState({
      showImportDepRoleModel: false
    })
  };
  hideImportErrInfoForDepRole = () => {
    this.setState({
      showImportErrInfoForDepRole: false
    })
  };
  showImportErrInfoForDepRole = () => {
    this.setState({
      showImportErrInfoForDepRole: true
    })
  };
  //下载模板：部门角色导入模板
  downloadTemplateDepRole = () => {
    this.setState({
      downloading: true,
    });
    OrgService.downloadDepRoleTemplate()
      .then((res) => {
        let b = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
        //部门角色导入模板
        let name = messages('enterprise-manage.key402')/*维护部门附属字段信息*/;
        FileSaver.saveAs(b, `${name}.xlsx`);
        this.setState({
          downloading: false,
        });
      })
      .catch((res) => {
        this.setState({
          downloading: false,
        });
      })
  };

  //导入部门信息
  handleFileUploadForRole = () => {
    const {fileList} = this.state;
    const formData = new FormData();
    formData.append('file', fileList[0]);
    this.setState({
      uploading: true,
      flieUploading: true,
    });

    OrgService.importTemplateDepRole(formData)
      .then((res) => {
        this.setState({
          fileList: [],
          uploading: false,
          flieUploading: false,
          showImportDepRoleModel: false,
          transactionOID: res.data.transactionOID//这个transactionOID在导出错误信息的时候，需要用到
        }, () => {
          this.showImportErrInfoForDepRole();
          this.showTransactionLogDialog(this.state.transactionOID);   // 将参数传给dialog
        });
      })
      .catch((res) => {
        this.setState({
          uploading: false,
          flieUploading: false,
        });
      })
  };

  //导入时错误信息
  showTransactionLogDialog = (transactionOID) => {
    OrgService.getDepRoleBatchTransactionLog(transactionOID)
      .then((res) => {
        let data = res.data;
        if (data.totalEntities === 0) {
          this.hideImportErrInfoForDepRole();
          return;
        } else {
          let errors = data.errors;
          let errorsList = this.getErrorDataByerrors(errors);
          let progressImportErrInfo = this.getProgressByData(data);
          this.setState({
            progressImportErrInfo,
            errorsList
          })
          if ((data.successEntities + data.failureEntities) !== data.totalEntities) {
            let gapTime = 500;
            setTimeout(() => {
              //请求频率涉及到一个算法
              this.showTransactionLogDialog(this.state.transactionOID);   // 将参数传给dialog
            }, gapTime)
          } else {
            //导入完成了
            if (this.state.errorsList.length === 0 && progressImportErrInfo === 100) {
              message.success(messages('enterprise-manage.key381')/*导入成功，请刷新页面*/);
              this.hideImportErrInfoForDepRole();
            }
          }
        }
      })
  };
  //获取百分进度
  getProgressByData = (data) => {
    return Math.round((data.failureEntities + data.successEntities) * 100 / data.totalEntities);
  };
  //通过错误信息，解析成表格
  getErrorDataByerrors = (errs) => {
    let data = [];
    for (let key in errs) {
      let row = {};
      row.line = errs[key];
      if (row.line.length > 1) {
        let _line = [];
        for (let i = 0; i < row.line.length; i++) {
          _line.push(row.line[i]);
          if (i < row.line.length - 1) {
            _line.push(",");
          }
        }
        row.line = _line;
      }
      row.msg = key;
      data.push(row);
    }
    return data;
  };
  //导出错误信息
  exportFailedLogDepRole = () => {
    OrgService.exportDepRoleBatchTransactionLog(this.state.transactionOID)
      .then((res) => {
        let b = new Blob([res.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
        let name = messages('enterprise-manage.key181'/*部门角色导入错误信息*/);
        FileSaver.saveAs(b, `${name}.xlsx`);
      })
  };
  // todo 待优化 用导入组件end
  // ---------------批量设置角色  end------------------
  // 查询所有集团部门
  //是否是删除操作
  getTenantAllDep(isDelete) {
    let {selectedKeysDepData, selectedKeys, companyOID} = this.state;
    let params = {
      companyOID
    };
    this.setState({
      listLoading: true
    });
    //新接口获取全部部门，子部门
    OrgService.getTenantAllDepV2(this.state.showDisabledDepChange, params)
      .then((response) => {
        this.setState({
          listLoading: false,
          treeData: response,
          selectedKeysDepData: selectedKeys.length ? selectedKeysDepData : response.length ? response[0].originData : {},
          selectedKeys: selectedKeys.length ? selectedKeys : response.length ?  [response[0].key] : undefined
        }, () => {
          let {selectedKeysDepData, selectedKeysDepDataByApi} = this.state;
          //如果删除了激活的节点，重新激活第一个节点
          if (isDelete && selectedKeysDepData.departmentOID === selectedKeysDepDataByApi.departmentOID) {
            this.setState({
              treeData: response,
              selectedKeysDepData: response.length ? response[0].originData : {},
              selectedKeys: response.length ?  [response[0].key] : undefined
            }, () => {
              let {selectedKeysDepData} = this.state;
              this.getDepDetailByDepOID(selectedKeysDepData);
              this.getDepUserByDepOID(selectedKeysDepData);
            })
          } else {
            if (selectedKeysDepData.departmentOID !== selectedKeysDepDataByApi.departmentOID) {
              this.getDepDetailByDepOID(selectedKeysDepData);
              this.getDepUserByDepOID(selectedKeysDepData);
            }
          }
        });
      })
      .catch(err => {
        this.setState({
          listLoading: false,
        });
      })
  }

  // 通过部门oid查询部门详情
  getDepDetailByDepOID(Dep) {
    OrgService.getDepDetailByDepOID(Dep)
      .then((response) => {
        let data = response.data;
        data.departmentPositionDTOList = OrgService.sortDepartmentPositionDTOList(data.departmentPositionDTOList);
        //todo
        //把是否可以关联公司的账套挂在data上面
        data.isEnableDepCompany = this.state.isEnableDepCompany;
        this.setState({
          selectedKeysDepDataByApi: data
        }, () => {
          if (data.customFormValues && data.customFormValues.length > 0) {
            this.getPersonDetailEnumerationList();
          }
        });
      })
  }

  /*
  * 这个地方借用人员信息扩展字段列表数据封装
  * 获取扩展字段中的值列表
  * */
  getPersonDetailEnumerationList = () => {
    let personObj = this.state.selectedKeysDepDataByApi;
    let customFormValues = personObj.customFormValues;
    for (let i = 0; i < customFormValues.length; i++) {
      if (customFormValues[i].messageKey === "cust_list") {
        let dataSource = null;
        try {
          dataSource = JSON.parse(customFormValues[i].dataSource);
        } catch (e) {
        }
        if (dataSource && dataSource.customEnumerationOID) {
          PDService.getListByCustomEnumerationOID(dataSource.customEnumerationOID)
            .then((res) => {
              this.setPersonDetailEnumerationList(res.data, customFormValues[i])
            })
        }
      }
    }
  }
  /*
  * 这个地方借用人员信息扩展字段列表数据封装
  * 设置扩展字段中的值列表
  * 把值列表挂在对应字段上
  * */
  setPersonDetailEnumerationList = (customEnumerationList, filed) => {
    let personObj = deepCopy(this.state.selectedKeysDepDataByApi);
    let customFormValues = personObj.customFormValues;
    for (let i = 0; i < customFormValues.length; i++) {
      if (customFormValues[i].fieldOID === filed.fieldOID) {
        customFormValues[i].customEnumerationList = customEnumerationList;
        /*
        * 这里应该不会涉及与其他系统进行同步，如果要与其他系统同步
        * 则需要：
        * 每设置一次，都需要更新一下
        * 后端可能返回的是值列表值对应的 code（value），不是 messageKey，需要找一下
        * 参见 bug13014
        * */
        this.setState({
          selectedKeysDepDataByApi: personObj
        })
      }
    }
  };

  // 通过部门oid查询部门下面的员工
  getDepUserByDepOID(Dep) {
    this.setState({loading: true});
    const {pagination} = this.state;
    let params = {
      departmentOID: Dep.departmentOID,
      size: this.state.pagination.pageSize,
      page: this.state.pagination.page,
      // status: 1001,
      searchType: "department",
      keyword: ""
    };
    OrgService.searchPersonPosition(params)
      .then((response) => {
        pagination.total = Number(response.headers['x-total-count']);
        this.setState({
          pagination,
          loading: false,
          depUserData: response.data
        }, () => {
          this.refreshRowSelection();
        });
      })
  }


  //只搜部门：这个没有异步
  onlySearchDep = (e) => {
    const value = e.target.value;
    //这个搜索可以不用节流函数
    if (value && value.length > 0) {
      this.setState({
        listLoading: true
      });
      OrgService.onlySearchDep(value)
        .then((res) => {
          this.setState({
            treeData: res,
            listLoading: false,
          });
        })
        .catch(err => {
          this.setState({
            listLoading: false,
          });
        })
    } else {
      this.getTenantAllDep();
    }
  };
  // 点击被选择
  onSelect = (selectedKeys, info) => {
    let _this = this;
    if (this.state.roleIsEdit) {
      confirm({
        title: messages('enterprise-manage.key182'/*提示*/),
        content: messages('enterprise-manage.key183'/*部门正在编辑没有保存，是否跳转?*/),
        onOk() {
          _this.onSelectConfrim(selectedKeys, info)
        },
        onCancel() {
        },
      });
    } else {
      this.onSelectConfrim(selectedKeys, info)
    }
  };
  onSelectConfrim = (selectedKeys, info) => {
    const {pagination} = this.state;
    pagination.page = 0;
    pagination.current = 1;
    this.setState({
      pagination,
      depNeedMoveOut: [],
      selectedRowKeys: []
    });
    if (info.selectedNodes.length > 0) {
      let selectedKeysDepData = info.selectedNodes[0].props.dataRef.originData;
      this.setState({
        selectedKeys: selectedKeys,
        selectedKeysDepData: selectedKeysDepData
      });
      this.getDepDetailByDepOID(selectedKeysDepData);
      this.getDepUserByDepOID(selectedKeysDepData);
    }
  };
  // 点击展开的时候
  onExpand = (expandedKeys, {expanded, node}) => {
    this.setState({
      expandedKeys,
      autoExpandParent: false,
    });
  };
  // 部门树上节点的菜单------start---
  //组织架构树顶部的meun
  renderOrgMoreMeun = () => {
    return (
      <Menu>
        <Menu.Item key="-1">
          <div onClick={(event) => {
            this.enableDepCompany()
          }}> {messages('enterprise-manage.key353')/*部门关联公司设置*/}
          </div>
        </Menu.Item>
        <Menu.Item key="0">
          <div onClick={(event) => {
            this.goToRolesList()
          }}>
            {messages('enterprise-manage.key184'/*设置部门角色*/)}</div>
        </Menu.Item>
        {/*与宗云，罗志鹏达成一致，占时关闭此功能（岗位信息移动）*/}
        {/*<Menu.Item key="1">*/}
        {/*  <div onClick={(event) => {*/}
        {/*    this.showBatchAdjustment()*/}
        {/*  }}>{messages('enterprise-manage.key185')}*/}
        {/*  </div>*/}
        {/*</Menu.Item>*/}
        <Menu.Item key="2">
          <div onClick={(event) => {
            this.clickMeunNewDep(event, {}, {})
          }}>{messages('enterprise-manage.key186'/*创建部门*/)}
          </div>
        </Menu.Item>
        <Menu.Item key="department-extend-filed">
          <div onClick={(event) => {
            this.goToDepartmentExtendFiled()
          }}> {messages('enterprise-manage.key187'/*部门扩展字段*/)}
          </div>
        </Menu.Item>
        <Menu.Item key="3">
          <div onClick={(event) => {this.batchSettingRole()}}>
            {messages('enterprise-manage.key402')/*维护部门附属字段信息*/}
          </div>
        </Menu.Item>
        <Menu.Item key="5">
          <ExportModal
            codeCheck={true}
            exportTitle={messages('enterprise-manage.key189'/*批量导出部门信息*/)}
            exportType="DEPARTMENT_POSITION_USER"
            exportCommand={"department_position_user"}
          />
        </Menu.Item>
      </Menu>
    )
  }

  //部门操作菜单
  treeNodeSettingClick = (e) => {
    e.stopPropagation();
  }
  // 停用该部门
  disabledDep = (item) => {
    let oid = item.departmentOID;
    let that = this;
    confirm({
      title: messages('enterprise-manage.key366')/*确认停用该部门吗?*/,
      content: messages('enterprise-manage.key367')/*停用之后，将无法再次启用*/,
      onOk() {
        OrgService.disabledDep(oid)
          .then((res) => {
            that.getTenantAllDep(!that.state.showDisabledDepChange);
          })
          .catch((res) => {
            let message = getErrorMessage(res.response);
            Modal.warning({
              title: messages('enterprise-manage.key182'/*提示*/),
              content: message,
            });
          })
      },
      onCancel() {
      },
    });
  };
  // 启用该部门
  enabledDep = (item, node) => {
    let oid = item.departmentOID;
    OrgService.enabledDep(oid)
      .then((res) => {
        this.getTenantAllDep();
      })
  };
  //创建平级部门
  clickMeunNewDep = (e, item, node) => {
    item.c_type = "C_DEP";
    item.isEnableDepCompany = this.state.isEnableDepCompany;
    item.treeNode = node;
    let slideFrame = {
      title: messages('enterprise-manage.key186'/*创建部门*/),
      visible: true,
      params: item
    }
    this.setState({
      slideFrame
    })
  };
  //创建子部门
  clickMeunNewChildDep = (e, item, node) => {
    item.treeNode = node;
    item.isEnableDepCompany = this.state.isEnableDepCompany;
    //传入的部门
    item.c_type = "C_CHILD";
    let slideFrame = {
      title: messages('enterprise-manage.key190'/*创建子部门*/),
      visible: true,
      params: item
    };
    this.setState({
      slideFrame
    })
  }
  //删除部门
  clickMeunDeleteDep = (item) => {
    let oid = item.departmentOID;
    OrgService.deleteDep(oid)
      .then((res) => {
        this.getTenantAllDep(true);
      })
      .catch((res) => {
        let message = getErrorMessage(res.response);
        Modal.warning({
          title: messages('enterprise-manage.key182'/*提示*/),
          content: message,
        });
      })
  };
  updateDepSuccess = () => {
    this.getTenantAllDep();
  }
  // 部门树上节点的菜单------end---
  // 批量调整---start-----
  /*
  * 调出批量调整的模态框
  * todo 此功能被下，先不删除
  * */
  showBatchAdjustment() {
    this.setState({visibleBatchAdjustment: true})
  }

  handleBatchAdjustmentOk = () => {
    let userOIDs = [], oldDepartmentList = [];
    let batchAdjustmentFrom = this.state.batchAdjustmentFrom;
    for (let i = 0; i < batchAdjustmentFrom.length; i++) {
      let u_id = batchAdjustmentFrom[i].userOID;
      u_id ? userOIDs.push(u_id) : oldDepartmentList.push(batchAdjustmentFrom[i].departmentOID);
    }
    let params = {
      "departmentOID": this.state.batchAdjustmentTo[0].departmentOID,
      "userOIDs": userOIDs,
    }
    this.setState({loadingBatchAdjustment: true});
    //岗位信息调整
    //todo 此功能被下，先不做
    OrgService.batchMovePersonPosition(params)
      .then((response) => {
        this.setState({
          visibleBatchAdjustment: false,
          loadingBatchAdjustment: false
        });
        this.callbackBatchAdjustmentFrom([]);
        this.callbackBatchAdjustmentTo([]);
        //批量调整之后查询
        this.getDepDetailByDepOID(this.state.selectedKeysDepData);
        this.getDepUserByDepOID(this.state.selectedKeysDepData);
      })
      .catch(() => {
        this.setState({loadingBatchAdjustment: false});
      })
  }
  handleBatchAdjustmentCancel = () => {
    this.setState({visibleBatchAdjustment: false})
  }
  //批量调整部门：目标部门
  callbackBatchAdjustmentTo = (arr) => {
    this.setState({
      batchAdjustmentTo: arr
    }, () => {
      this.setBatchAdjustmentBtnEnabled();
    })
  }
  renderBatchAdjustmentTo = (arr) => {
    if (arr.length < 1) {
      return (<span> {messages('enterprise-manage.key191'/*还未选择*/)}</span>)
    } else {
      return (<span>{messages('enterprise-manage.key192'/*已选*/)} {arr[0].name}</span>)
    }
  }
  //批量调整部门：源部门与人
  callbackBatchAdjustmentFrom = (arr) => {
    this.setState({
      batchAdjustmentFrom: arr
    }, () => {
      this.setBatchAdjustmentBtnEnabled();
    })
  }
  setBatchAdjustmentBtnEnabled = () => {
    let disabledBatchAdjustment = true;
    if (this.state.batchAdjustmentFrom.length > 0 && this.state.batchAdjustmentTo.length > 0) {
      disabledBatchAdjustment = false;
    }
    this.setState({
      disabledBatchAdjustment
    })
  }
  // 批量调整---end-----
  // 当前部门人员------start------
  // 部门：移入员工
  moveInPerson = (arr) => {
    let userOIDs = [];
    let oldDepartmentList = [];
    //这个地方原则上只有移动员工，但是不排除以后加上部门下的员工
    for (let i = 0; i < arr.length; i++) {
      arr[i].userOID ? (arr[i]._postionId ? userOIDs.push(arr[i]._postionId) : userOIDs.push(arr[i].userOID)) : oldDepartmentList.push(arr[i].departmentOID);
    }
    let params = {
      "departmentOID": this.state.selectedKeysDepData.departmentOID,
      "userJobsIds": userOIDs,
    }
    this.setState({
      moveing: true
    })
    OrgService.batchMovePersonPosition(params)
      .then((response) => {
        this.setState({
          moveing: false
        })
        this.setState({visibleBatchAdjustment: false});
        this.getDepDetailByDepOID(this.state.selectedKeysDepData);
        this.getDepUserByDepOID(this.state.selectedKeysDepData);
      })
      .catch(()=>{
        this.setState({
          moveing: false
        })
      })
  }
  // 部门：移除员工
  moveOutPerson = (arr) => {
    let params = {
      "departmentOID": arr[0].departmentOID,
      "userJobsIds": this.state.depNeedMoveOut,
    }
    this.setState({
      moveing: true
    })
    OrgService.batchMovePersonPosition(params)
      .then((response) => {
        this.setState({
          moveing: false
        })
        this.clearRowSelection();
        this.getDepUserByDepOID(this.state.selectedKeysDepData);
        this.getDepDetailByDepOID(this.state.selectedKeysDepData);
      })
      .catch(()=>{
        this.setState({
          moveing: false
        })
      })
  }
  // 部门人员翻页
  onUserChangePager = (pagina, filters, sorter) => {
    let {pagination} = this.state;
    pagination.current = pagina.current;
    pagination.page = pagina.current - 1;
    pagination.pageSize = pagina.pageSize;

    this.setState({
      pagination
    }, () => {
      this.getDepUserByDepOID(this.state.selectedKeysDepData);
    })
  }
  //选中项发生变化的时的回调
  onSelectChange = (selectedRowKeys) => {
    this.setState({selectedRowKeys: selectedRowKeys});
  };
  //选择/取消选择某行的回调
  handleSelectRow = (record, selected) => {
    let depNeedMoveOut = this.state.depNeedMoveOut;
    selected ? depNeedMoveOut.push(record.id) : depNeedMoveOut.delete(record.id);
    this.setState({depNeedMoveOut})
  };
  //选择/取消选择所有行的回调
  handleSelectAllRow = (selected, selectedRows, changeRows) => {
    let depNeedMoveOut = this.state.depNeedMoveOut;
    if (selected) {
      changeRows.map(item => {
        depNeedMoveOut.push(item.id)
      })
    } else {
      changeRows.map(item => {
        depNeedMoveOut.delete(item.id)
      })
    }
    this.setState({depNeedMoveOut})
  };

  //换页后根据OIDs刷新选择框
  refreshRowSelection() {
    let selectedRowKeys = [];
    this.state.depNeedMoveOut.map(id => {
      this.state.depUserData.map((item, index) => {
        if (item.id === id)
          selectedRowKeys.push(index);
      })
    });
    this.setState({selectedRowKeys});
  }

  //清空选择框：选了的人
  clearRowSelection() {
    this.setState({depNeedMoveOut: [], selectedRowKeys: []});
  }

  //搜索部门下的人
  emitEmptyForDep = () => {
    this.userNameInput.focus();
    this.setState({userName: ''}, () => {
      this.onChangeUserName();
    });
  }
  //节流函数
  onChangeSetUserDepName2 = superThrottle(() => {
    this.onChangeUserName();
  }, 500, 3000);
  //为了节流函数
  onInputUserDepName2 = (e) => {
    this.setState({userName: getSubText(e.target.value,100)});
  };
  //搜索人名或者工号
  onChangeUserName = (e) => {
    const {pagination} = this.state;
    pagination.page = 0;
    this.setState({
      pagination,
      loading: true
    }, () => {
      let params = {
        departmentOID: this.state.selectedKeysDepData.departmentOID,
        size: this.state.pagination.pageSize,
        page: this.state.pagination.page,
        // status: 1001,
        roleType: "TENANT",
        searchType:"department",
        keyword: this.state.userName
      }
      OrgService.searchPersonPosition(params)
        .then((response) => {
          pagination.total = Number(response.headers['x-total-count']);
          this.setState({
            pagination,
            depUserData: response.data
          });
          this.setState({loading: false});
        })
    });
  }
  // 当前部门人员------end------
  // 搜索整个部门树与搜索结果----start
  //搜索整个部门树下面的部门与人
  //搜索人或者部门编码或部门名称
  onChangeUserDepName = (val) => {
    const {userDepName, showDisabledDepChange, companyOID} = this.state;
    this.setState({
      isSearchOver: false
    });
    //val不用设置了，在oninput设置过了
    OrgService.searchDepOrPersonV2(userDepName, showDisabledDepChange, companyOID)
      .then((response) => {
        let searchList = {
          depList: response.data.departments,
          personList: response.data.users
        }
        this.setState({
          isSearchOver: true,
          searchList: searchList
        });
      })
  }
  emitEmpty = () => {
    this.setState({userDepName: ''});
  }
  //搜索整个部门树下面的部门与人
  //为了节流函数
  onChangeSetUserDepName = superThrottle(() => {
    this.onChangeUserDepName();
  }, 500, 3000);
  //为了节流函数
  onInputUserDepName = (e) => {
    //这句是为了使用节流函数，不然onChangeSetUserDepName函数中只能使用上一次的输入
    this.state.userDepName = getSubText(e.target.value, 100);
    this.setState({userDepName: getSubText(e.target.value, 100)});
  }

  //部门树搜索结果点击目标
  selectItemHandle = (item) => {
    if (item.userOID) {
      this.setState({
        searchActiveUser: item
      })
    } else {
      this.setState({
        searchActiveUser: item,
        selectedKeys: [item.departmentOID],
        selectedKeysDepData: item
      })
      this.getDepDetailByDepOID(item);
      this.getDepUserByDepOID(item);
    }
  }
  onShowDisabledDepChange = (e) => {
    this.setState({
      showDisabledDepChange: e.target.checked
    }, () => {
      this.getTenantAllDep();
    })
  }
  //渲染部门树或者搜索结果
  renderOrgTreeOrSearchList = (e) => {
    const {listLoading} = this.state;
    if (this.state.userDepName.length > 0) {
      return <div>
        <OrgSearchList
          isSearchOver={this.state.isSearchOver}
          searchList={this.state.searchList}
          selectItemHandle={this.selectItemHandle}
        />
      </div>
    } else {
      return <div>
        <div>
          <Checkbox
            checked={this.state.showDisabledDepChange}
            onChange={this.onShowDisabledDepChange}>{messages('enterprise-manage.key336')/*显示停用的部门*/}</Checkbox>
        </div>
        {
          listLoading ? <Spin spinning={listLoading}/>
            :
            <OrgTree
              ROLE_TENANT_ADMIN={this.props.tenantMode}
              CREATE_DATA_TYPE={(parseInt(this.props.company.createDataType) !== 1002)}
              onlySearchDep={this.onlySearchDep}
              enabledDep={this.enabledDep}
              disabledDep={this.disabledDep}
              treeData={this.state.treeData}
              selectedKeys={this.state.selectedKeys}
              expandedKeys={this.state.expandedKeys}
              autoExpandParent={this.state.autoExpandParent}
              onSelect={this.onSelect}
              onExpand={this.onExpand}
              treeNodeSettingClick={this.treeNodeSettingClick}
              clickMeunDeleteDep={this.clickMeunDeleteDep}
              clickMeunNewDep={this.clickMeunNewDep}
              clickMeunNewChildDep={this.clickMeunNewChildDep}
            />
        }
      </div>
    }
  }
  // 搜索整个部门树与搜索结果----end
  //获取角色是否在编辑
  getRoleIsEdit = (isEdit, obj) => {
    this.setState({
      roleIsEdit: isEdit
    })
    if (obj && obj.departmentOID) {
      this.getDepDetailByDepOID(obj);
    }
  }
  //渲染部门详情获取人员详情
  renderDepOrPersonInfo = () => {
    let {moveing} = this.state;
    let rowSelection = '';
    if (this.props.tenantMode && (parseInt(this.props.company.createDataType) !== 1002)) {
      rowSelection = {
        selectedRowKeys: this.state.selectedRowKeys,
        onChange: this.onSelectChange,
        onSelect: this.handleSelectRow,
        onSelectAll: this.handleSelectAllRow
      };
    } else {
      rowSelection = null
    }
    //如果是搜索结果还有选择的人员，如果选择的部门也需要展示部门详情
    if (this.state.userDepName.length > 0 && this.state.searchActiveUser.userOID) {
      return <OrgPersonInfo user={this.state.searchActiveUser}/>
    } else {
      //TODO
      const {userName, selectedKeysDepDataByApi} = this.state;
      const suffix = userName ? <Icon type="close-circle" onClick={this.emitEmptyForDep}/> : null;
      return <div>
        <div className="role-pannel">
          <OrgRoles
            ROLE_TENANT_ADMIN={this.props.tenantMode}
            CREATE_DATA_TYPE={(parseInt(this.props.company.createDataType) !== 1002)}
            managerIsRequired={!this.props.profile["department.manager.required.disable"]}
            disabledDep={this.disabledDep}
            clickMeunNewChildDep={this.clickMeunNewChildDep}
            updateDepSuccess={this.updateDepSuccess}
            emitIsEdit={this.getRoleIsEdit}
            selectedKeysDepDataByApi={this.state.selectedKeysDepDataByApi}
            selectedKeysDepData={this.state.selectedKeysDepData}
            selectedKeys={this.state.selectedKeys}>
          </OrgRoles>
        </div>
        <div className="dep-users">
          <div className="table-header-wrap">
            <div className="table-header-buttons">
              {/*移入员工*/}
              <div className="f-left">
                <SelectDepOrPerson
                  searchType={'position'}
                  buttonType={"primary"}
                  buttonDisabled={moveing || !this.props.tenantMode || !(parseInt(this.props.company.createDataType) !== 1002) || selectedKeysDepDataByApi.status + "" !== "101"}
                  title={messages('enterprise-manage.key193'/*移入员工*/)}
                  onlyPerson={true}
                  onConfirm={this.moveInPerson}/>
              </div>
              <div className="f-left">
                <SelectDepOrPerson
                  buttonType={"primary"}
                  buttonDisabled={
                    moveing ||
                    this.state.depNeedMoveOut.length < 1 ||
                    !this.props.tenantMode ||
                    !(parseInt(this.props.company.createDataType) !== 1002)}
                  title={messages('enterprise-manage.key194'/*移出员工*/)}
                  multiple={false}
                  onlyDep={true}
                  onConfirm={this.moveOutPerson}/>
              </div>
              <div className="clear"/>
            </div>
            <div className="table-header-inp">
              <Input
                key={'depsearch'}
                placeholder={messages('enterprise-manage.key195'/*员工名称/工号*/)}
                prefix={<Icon type="search" className='font-disabled'/>}
                suffix={suffix}
                value={userName}
                onInput={this.onInputUserDepName2}
                onChange={this.onChangeSetUserDepName2}
                ref={node => this.userNameInput = node}
              />
            </div>
            <div className="clear"/>
          </div>
          <ResizeTable
            dataSource={this.state.depUserData}
            loading={moveing ||this.state.loading}
            pagination={this.state.pagination}
            onChange={this.onUserChangePager}
            columns={this.state.columns}
            rowKey={'id'}
            rowSelection={rowSelection}
            size="middle"
            bordered/>
        </div>
      </div>
    }
  }
  //关闭侧边导航：部门编辑\新增子部门\新增平级部门
  handleCloseSlide = () => {
    let slideFrame = this.state.slideFrame;
    slideFrame.visible = false;
    this.getTenantAllDep();
    this.setState({
      slideFrame,
    });
  }
  renderOrgMoreMeunByRole = () => {
    if (this.props.tenantMode && (parseInt(this.props.company.createDataType) !== 1002)) {
      return (
        <div className='f-right org-structure-tree-title-setting'>
          <Dropdown overlay={
            this.renderOrgMoreMeun()
          } trigger={['click']}>
            <a className="ant-dropdown-link">
              <Icon type="setting"/>
            </a>
          </Dropdown>
        </div>
      )
    } else {
      return null;
    }
  }
  onDCChangeSwitch = (val) => {
    this.setState({
      isEnableDepCompany: val === true ? "OPEN" : val === "INIT" ? "INIT" : "CLOSE"
    });
  }
  onDCChangeSwitchSet = (val, failCallback) => {
    let noTip = true;
    let params = {
      "tenantId": this.props.user.tenantId,
      "companyControlStatus": (val === true || val === "OPEN") ? "OPEN" : "CLOSE"
    };
    if (val === undefined || val === null) {
      noTip = false;
      params = {
        "tenantId": this.props.user.tenantId,
        "companyControlStatus": this.state.isEnableDepCompany === "OPEN" ? "OPEN" : "CLOSE"
      };
      //当不是取消的情况，有弹窗提示
      this.setState({
        visibleForCheckDepCompany: true
      })
    }
    let timestamp = (new Date()).getTime();
    OrgService.setEnableDepCompany(params, timestamp)
      .then((res) => {
        //有了轮询接口，这里不用处理
      })
      .catch(() => {
        this.setState({
          visibleForCheckDepCompany: false
        })
        failCallback();
      })
    this.getEnableDepCompanyStatus(timestamp, failCallback, noTip);
  };
  //轮询获取状态
  getEnableDepCompanyStatus = (timestamp, failCallback, noTip) =>{
    let timerDepCompanyStatus = null;
    OrgService.getEnableDepCompanyStatus(timestamp)
      .then(res=>{
        if (res.data.result + "" === "true") {
          this.setState({
            visibleForCheckDepCompany: false
          })
          configureStore.store.dispatch(setEnableDepCompany(res.data.companyControlStatus));
          this.setState({
            isEnableDepCompany: res.data.companyControlStatus
          });
          if (!noTip) {
            if (res.data.companyControlStatus === "OPEN") {
              message.success(messages('enterprise-manage.key354')/*开启成功*/);
            } else {
              message.success(messages('enterprise-manage.key355')/*关闭成功*/);
            }
          }
        }else if(res.data.result + "" === "false"){
          this.setState({
            visibleForCheckDepCompany: false
          })
          let companyErr = res.data.deptCompanyErrorLogPath;
          let userErr = res.data.userDeptCompanyErrorPath;
          failCallback();
          Modal.error({
            title: messages('enterprise-manage.key356')/*启用失败*/,
            content: <div>
              {companyErr && <h5>
                <span>{messages('enterprise-manage.key357')/*部门未关联公司，部门上公司不符合规范*/}</span>
                <a target="_blank" href={companyErr}> {messages('enterprise-manage.key358')/*下载查看*/} &gt;</a>
              </h5>}
              {userErr && <h5>
                <span>{messages('enterprise-manage.key359')/*人员上的公司与部门对应的公司不一致*/}</span>
                <a target="_blank" href={userErr}> {messages('enterprise-manage.key358')/*下载查看*/} &gt;</a>
              </h5>}
            </div>,
            onOk() {
            },
            onCancel() {
            },
          })
        }else {
          timerDepCompanyStatus = setTimeout(()=>{
            clearTimeout(timerDepCompanyStatus);
            this.getEnableDepCompanyStatus(timestamp, failCallback, noTip);
          },800)
        }
      })
      .catch(()=>{
        this.setState({
          visibleForCheckDepCompany: false
        })
        failCallback();
      })
  };

  //{messages('enterprise-manage.key360')/*是否启用部门关联公司*/}
  enableDepCompany = () => {
    const {isEnableDepCompany} = this.state;
    //用来做取消的
    let originStatus = deepCopy(isEnableDepCompany);
    let that = this;
    Modal.confirm({
      title: messages('enterprise-manage.key360')/*是否启用部门关联公司*/,
      content: <div>
        <p><Switch defaultChecked={isEnableDepCompany === "OPEN"} onChange={this.onDCChangeSwitch}>
          {isEnableDepCompany === "OPEN" ? messages('common.status.enable') : messages('common.disabled')}
        </Switch></p>
        <p/>
        <h5>{messages('enterprise-manage.key361')/* 1.启用后支持部门关联公司管控，一个部门只能属于一个公司，且不支持修改。*/}</h5>
        <h5>{messages('enterprise-manage.key362')/* 2. 当开关启用后，人上的部门和公司须与部门上的公司一致 */}</h5>
      </div>,
      onOk() {
        that.onDCChangeSwitchSet(null, () => {
          that.onDCChangeSwitch(originStatus);
        });
      },
      onCancel() {
        that.onDCChangeSwitch(originStatus);
        that.onDCChangeSwitchSet(originStatus);
      },
    });
  };

  handleCompanyFilterChange = (val) => {
    let companyName = val && val[0] ? val[0].companyName : undefined;
    let companyOID = val && val[0] ? val[0].companyOID : undefined;
    let params = {
      companyOID
    }
    this.setState({
      companyOID,
      companyName
    },()=>{
      //不然账号切换之后还存在
      OrgService.resetTreeList();
      this.getTenantAllDep();
    })

  }

  //渲染入口
  render() {
    let {userDepName, downloading, isEnableDepCompany, companyName, companyOID} = this.state;
    let {tenantMode} = this.props;
    let wrapClass = isEnableDepCompany === "OPEN" ? "org-structure-tree-title-wrap more100" : "org-structure-tree-title-wrap";
    let suffix = userDepName ? <span className="org-search-icon"><Icon type="close-circle" onClick={this.emitEmpty}/></span> : null;
    let props = {
      onRemove: (file) => {
        this.setState(({fileList}) => {
          const index = fileList.indexOf(file);
          const newFileList = fileList.slice();
          newFileList.splice(index, 1);
          return {
            fileList: newFileList,
          };
        });
      },
      beforeUpload: (file) => {
        this.setState(({fileList}) => ({
          fileList: [file],
        }));
        return false;
      },
      fileList: this.state.fileList,
    };
    return (
      <div className="org-structure">
        <div className="f-left org-structure-left">
          <div className={wrapClass}>
            <div className='f-left org-structure-tree-title'>
              {messages('enterprise-manage.key196'/*组织架构*/)}
            </div>
            {this.renderOrgMoreMeunByRole()}
            <div className='clear'/>
            {isEnableDepCompany === "OPEN" && <div className='org-structure-company-filter'>
              <Chooser single={true}
                       type="all_company_with_legal_entity"
                       labelKey="companyName"
                       valueKey="companyOID"
                       disabled={!tenantMode}
                       value={companyName ? [{
                         companyName: companyName,
                         companyOID: companyOID
                       }] : undefined}
                       onChange={this.handleCompanyFilterChange}
                       listExtraParams={{}}/>
            </div>}
            {/*部门名称/部门编码/员工名称*/}
            <Search
              placeholder={messages('enterprise-manage.key197'/*部门名称/部门编码/员工名称*/)}
              enterButton={<span>
                {messages('enterprise-manage.key198'/*搜索*/)}
                    </span>}
              prefix={<Icon type="search" className='font-disabled'/>}
              suffix={suffix}
              value={userDepName}
              key={'search-user-dep-name'}
              onInput={this.onInputUserDepName}
              onChange={this.onChangeSetUserDepName}
              onSearch={this.onChangeUserDepName}
            />
          </div>
          {this.renderOrgTreeOrSearchList()}
        </div>
        <div className="org-structure-right">
          {/*这个根据搜索结果来判断*/}
          {this.renderDepOrPersonInfo()}
        </div>
        <div className="clear"/>
        {/*批量调整的模态框，先选择部门与人，再选择目标部门,*/}
        {/*这个功能占时下架，就是批量选择部门或者人员，移到到另一个部门，由于新增了功能涉及到一人多岗，此功能后端逻辑影响太大*/}
        <Modal
          className="org-batch-adjustment-model"
          title={messages('enterprise-manage.key185'/*批量调整*/)}
          width={400}
          onCancel={this.handleBatchAdjustmentCancel}
          visible={this.state.visibleBatchAdjustment}
          footer={[
            <Button key="back" onClick={this.handleBatchAdjustmentCancel}>
              {messages('enterprise-manage.key199'/*取消*/)}
            </Button>,
            <Button key="submit"
                    disabled={this.state.disabledBatchAdjustment}
                    type="primary"
                    loading={this.state.loadingBatchAdjustment}
                    onClick={this.handleBatchAdjustmentOk}>
              {messages('enterprise-manage.key200'/*确定*/)}
            </Button>,
          ]}
        >
          <h3>
            {messages('enterprise-manage.key201'/*请选择*/)}
            <b>{messages('enterprise-manage.key202'/*部门或人*/)}</b>
            {messages('enterprise-manage.key203'/*移到*/)}
            <b>{messages('enterprise-manage.key204'/*另一个部门*/)}</b>
          </h3>
          <div>
            <div className="f-left batch-adjustment-from">
              <div>
                <SelectDepOrPerson
                  title={messages('enterprise-manage.key205'/*选择部门或人*/)}
                  onConfirm={this.callbackBatchAdjustmentFrom}/>
              </div>
              <div className="tips-box">
                {messages('enterprise-manage.key206'/*已选择*/)}
                {this.state.batchAdjustmentFrom.length}
                {messages('enterprise-manage.key207'/*条数据*/)}
              </div>
            </div>
            <div className="f-left middle-text">
              {messages('enterprise-manage.key208'/*移入到*/)}
            </div>
            <div className="f-left batch-adjustment-to">
              <div>
                <SelectDepOrPerson
                  title={messages('enterprise-manage.key209'/*选择目标部门*/)}
                  multiple={false}
                  onlyDep={true}
                  onConfirm={this.callbackBatchAdjustmentTo}/>
              </div>
              <div className="tips-box">
                {this.renderBatchAdjustmentTo(this.state.batchAdjustmentTo)}
              </div>
            </div>
            <div className="clear"/>
          </div>
        </Modal>

        {/*新增部门，编辑部门*/}
        <SlideFrame title={this.state.slideFrame.title}
                    show={this.state.slideFrame.visible}
                    isShowCloseBtn={false}
                    content={OrgNewDep}
                    afterClose={this.handleCloseSlide}
                    onClose={() => this.setState({slideFrame: {visible: false}})}
                    params={this.state.slideFrame.params}/>
        {/*部门角色*/}
        <Modal
          closable
          width={800}
          className="pm-import-person-modal"
          title={messages('enterprise-manage.key35'/*导入*/)}
          visible={this.state.showImportDepRoleModel}
          footer={null}
          onCancel={this.cancelImportForPerson}
          destroyOnClose={true}
        >
          <div className="import-person-modal-wrap">
            <div className="f-left import-person-modal-left">
              <div>
                <p>{messages('enterprise-manage.key210'/*1.创建导入文件*/)}</p>
                <p>{messages('enterprise-manage.key211'/*2.严格按照导入模板整理数据，检查必输事项是否缺少数据*/)}</p>
                <p>{messages('enterprise-manage.key212'/*3.关闭文件后，方可进行数据导入*/)}</p>
              </div>
              <Button
                onClick={this.downloadTemplateDepRole}
                className='default-color-font'
                style={{border: 'none'}}
                size={'small'}
                icon="download"
                loading={downloading}
              >
                {messages('enterprise-manage.key403')/*维护部门附属字段模板*/}
              </Button>

            </div>
            <div className="f-right import-person-modal-right">
              <div className="import-person-right-tips">
                {messages('enterprise-manage.key214'/*上传模板*/)}
              </div>
              <div className="upload-file-wrap">
                <Upload {...props}>
                  <Button>
                    <Icon type="upload"/>
                    {messages('enterprise-manage.key42'/*选择一个文件*/)}
                  </Button>
                </Upload>
                <Button
                  className="upload-file-start"
                  type="primary"
                  onClick={this.handleFileUploadForRole}
                  disabled={this.state.fileList.length === 0}
                  loading={this.state.flieUploading}
                >
                  {this.state.flieUploading ? messages('enterprise-manage.key43'/*上传中*/) : messages('enterprise-manage.key44'/*开始上传*/)}
                </Button>

              </div>
            </div>
            <div className="clear"/>
          </div>
        </Modal>
        {/*部门角色-人员*/}
        <ImportErrInfo
          progress={this.state.progressImportErrInfo}
          cancel={this.hideImportErrInfoForDepRole}
          exportErrInfo={this.exportFailedLogDepRole}
          errorsList={this.state.errorsList}
          visible={this.state.showImportErrInfoForDepRole}/>
        <Modal
          closable={false}
          title={null}
          footer={null}
          visible={this.state.visibleForCheckDepCompany}
        >
          <div>
            <Spin/>&nbsp;&nbsp;
            <span>{messages('enterprise-manage.key363')/*正在检查数据,请稍后...*/}</span>
          </div>
        </Modal>
      </div>
    )
  }
}

OrgStructure.contextTypes = {
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {
    profile: state.login.profile,
    user: state.login.user,
    company: state.login.company,
    tenantMode: state.main.tenantMode,
    enableDepCompany: state.setting.enableDepCompany,
  }
}

export default connect(mapStateToProps)(OrgStructure);
